from rest_framework import serializers

import settings
from social.notification.models import Notification
from social.user.serializers import SimpleUserSerializer


class NotificationSerializer(serializers.ModelSerializer):
    user = serializers.SerializerMethodField()
    thumb = serializers.SerializerMethodField()

    def get_thumb(self, instance):
        return settings.IMAGE_HOST + instance.thumb

    def get_user(self, instance):
        return SimpleUserSerializer(instance.from_user).data

    class Meta:
        model = Notification
        fields = ('user', 'content', 'type', 'link', 'thumb', 'created_at')
